/**
* Created by wl
* 基金储备库-管理机构信息
*/
<template>
    <div class="ca-p-20 ca-m-t-28">
        <div v-if="!showEdit">
            <div class="ca-title">
                <h3>管理机构信息</h3>
                <el-button type="text"  class="ca-edit-btn el-icon-edit ca-right" @click="showEdit = true" :disabled="!isAuthEditPre" v-if="$route.name.includes('pre-investment-funds')">编辑</el-button>
                <el-button type="text" class="ca-edit-btn el-icon-edit ca-right" @click="showEdit=true" :disabled="!isAuthEdit" v-else>编辑</el-button>
            </div>
            <el-form label-width="180px" :model="fundMechanism">
                <el-row>
                    <el-col :span="11">
                        <el-form-item label="机构名称：" class="el-form-item-m-b-0 el-form-item__content-font-12 el-break">
                            {{fundMechanism.mechanismName}}
                        </el-form-item>
                        <el-form-item label="执行事务合伙人：" class="el-form-item-m-b-0 el-form-item__content-font-12 el-break">
                            {{fundMechanism.partner}}
                        </el-form-item>
                        <el-form-item label="成立时间：" class="el-form-item-m-b-0 el-form-item__content-font-12 el-break">
                            {{fundMechanism.foundingTime == null ? '' : $moment(fundMechanism.foundingTime).format('YYYY-MM-DD')}}
                        </el-form-item>
                        <el-form-item label="认缴金额（万元）：" class="el-form-item-m-b-0 el-form-item__content-font-12 el-break">
                            {{fundMechanism.subscribed | format1}}
                        </el-form-item>
                    </el-col>
                    <el-col :span="11">
                        <el-form-item label="法定代表人：" class="el-form-item-m-b-0 el-form-item__content-font-12 el-break">
                            {{fundMechanism.representative}}
                        </el-form-item>
                        <el-form-item label="注册地址：" class="el-form-item-m-b-0 el-form-item__content-font-12 el-break">
                            {{registeredAddress}}
                        </el-form-item>
                        <el-form-item label="注册资本（万元）：" class="el-form-item-m-b-0 el-form-item__content-font-12 el-break">
                            {{fundMechanism.register | format1}}
                        </el-form-item>
                        <el-form-item label="实缴金额（万元）：" class="el-form-item-m-b-0 el-form-item__content-font-12 el-break">
                            {{fundMechanism.receipts | format1}}
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span='22'>
                        <el-form-item label="股东出资金额和比例：" class="el-form-item-m-b-0 el-form-item__content-font-12 el-break">
                            {{fundMechanism.proportion}}
                        </el-form-item>
                        <el-form-item label="公司治理：" class="el-form-item-m-b-0 el-form-item__content-font-12 el-break">
                            {{fundMechanism.govern}}
                        </el-form-item>
                        <el-form-item label="内控机制：" class="el-form-item-m-b-0 el-form-item__content-font-12 el-break">
                            {{fundMechanism.mechanism}}
                        </el-form-item>
                        <el-form-item label="管理制度：" class="el-form-item-m-b-0 el-form-item__content-font-12 el-break">
                            {{fundMechanism.rule}}
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
        </div>
        <csManagementAgency v-else @close="close" @update="update()"></csManagementAgency>
    </div>
</template>
<script type="text/ecmascript-6">
    import {api} from '../../api';
    import {STATUS_HTTP_SUCCESS, apiHttp} from '__service/csHttp';
    import { addRemind, isNoAuth } from '__service/utils';
    export default {
        data() {
            return {
                showEdit: false,
                isAuthEdit: isNoAuth('基金储备库-基金详情-编辑'),
                isAuthEditPre: isNoAuth('拟投资基金-基金详情-编辑'),
                registeredAddress: '', //注册地址
                fundMechanism: {
                    foundingTime: '', //成立时间
                    fundId: '', //基金id
                    govern: '', //公司治理
                    id: '', //主id
                    mechanism: '', //内控机制
                    mechanismName: '', //机构名称
                    partner: '', //执行事务合伙人
                    proportion: null, //股东出资金额和比例
                    receipts: null, //实收资本
                    region: [ //注册地址
                        {
                            businessId: '',
                            businessType: 1,
                            city: '',
                            district: '',
                            id: '',
                            province: '',
                            registrationDetailed: ''
                        }
                    ],
                    register: null, //注册资本
                    representative: '', //法定代表人
                    rule: '', //管理制度
                    subscribed: null //认缴金额
                },
            }
        },
        created() {
        },
        mounted() {
            this.getAgencyInfo()
        },
        props: {

        },
        watch: {
        },
        methods: {
            close() {
                this.showEdit = false
            },
            async update() {
                this.showEdit = false
                await this.getAgencyInfo()
                // 添加小红点
                await addRemind({
                    dataId: this.$route.params.itemId, // 业务id
                    dataTab: 0, // tab页顺序 head 也为0 新建为'-1'
                    dataType: 4, // 1拟投资项目,2已投资项目,3母基金,4拟设立基金,5已设立基金,6客户,7潜在项目
                });
                // 根据第三方组件来调用 父组件中定义的方法 重新获取小红点
                this.$root.Dot.$emit('getDotList');
                // 添加小红点 end
            },
            getAgencyInfo() {
                apiHttp(api.CHECK_MECHANISMINFO, {fundId: this.$route.params.itemId}).then(ret => {
                    if (ret.resCode === STATUS_HTTP_SUCCESS) {
                        this.fundMechanism = ret.data;
                        if (this.fundMechanism.region && this.fundMechanism.region.length > 0) {
                            this.registeredAddress = this.fundMechanism.region[0].registrationDetailed
                        }
                    }
                })
            },
        },
        components: {
            'csManagementAgency': require('./edit'),//管理机构信息edit页
        },
    }
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.ca-right {
    float: right;
}
.el-break {
    word-wrap: break-word;
}
</style>